using HTFramework.Core;
using UnityEngine;

public class MatchObjectPool
{
    static MatchObjectPool mInstance;

    public static MatchObjectPool Instance
    {
        get
        {
            if(mInstance == null)
                mInstance = new MatchObjectPool();
            return mInstance;
        }
    }

    ObjectPool<CellView> mCellViewPool;

    public void Init()
    {
        mCellViewPool = new ObjectPool<CellView>(81, pool => { return new CellView(); }, view => { }, view => { });
    }

    public CellView SpawnCellView(GameObject go)
    {
        CellView cellView = mCellViewPool.Spawn(true);
        cellView.OnSpawn(go);
        return cellView;
    }

    public void DespawnCellView(CellView cellView)
    {
        mCellViewPool.Despawn(cellView);
    }
}